package com.mtnz.njk.Controller;

import com.mtnz.njk.Service.IntegralManagerService;
import com.mtnz.njk.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @Description: 积分模块管理
 * @Author: FBL
 * @CreateDate: 2019\8\22 0022 16:22
 * @Version: 1.0
 */
@RestController
@RequestMapping("/integral")
@CrossOrigin
public class IntegralManagerController {
    @Autowired
    IntegralManagerService integralManagerService;

    /**
     * 积分订单列表
     *
     * @param key
     * @param beginTime
     * @param endTime
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @PostMapping("/listIntegralOrder")
    public ResponseResult integralOrder(String key, String beginTime, String endTime, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) throws Exception {
        return integralManagerService.integralOrder(key, beginTime, endTime, pageNum, pageSize);
    }

    /**
     * 添加物流信息
     *
     * @param expressNum
     * @param expressCompany
     * @return
     * @throws Exception
     */
    @PostMapping("/insertExpress")
    public ResponseResult insertExpress(Integer id, String expressNum, String expressCompany) throws Exception {
        return integralManagerService.insertExpress(id, expressNum, expressCompany);
    }

    /**
     * 积分订单Excel导出
     *
     * @return
     * @throws Exception
     */
    @GetMapping("/integralOrderExcel")
    public ResponseResult integralOrderExcel(HttpServletResponse response, String beginTime, String endTime) throws Exception {
        return integralManagerService.integralOrderExcel(response, beginTime, endTime);
    }

    /**
     * 积分变更审核列表
     *
     * @param key
     * @param integralType
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @PostMapping("/listAuditIntegral")
    public ResponseResult listAuditIntegral(String key,Integer integralType, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) throws Exception {
        return integralManagerService.listAuditIntegral(key, integralType, pageNum, pageSize);
    }

    /**
     *积分变动审核通过或拒绝
     *
     * @param audit
     * @return
     * @throws Exception
     */
    @PostMapping("/auditIntegral")
    public ResponseResult auditIntegral(Integer id,Integer audit) throws Exception {
        return integralManagerService.auditIntegral(id,audit);
    }

}
